****************************** ALL SIZE CLASS *******************************************************

clear
import delimited "C:\Users\abhin\Documents\Acads\CDS\employment_vars_state_indus_sizewise.csv"
cd "C:\Users\abhin\Documents\Acads\CDS\"

gen lab_prod_mandays_const = nva_const/ mandays_workers_multi
gen avg_wage_rate_mandays_const = wage_workers_const/ mandays_workers_multi

gen ln_lab_prod_mandays_const = log(nva_const/ mandays_workers_multi)
gen ln_avg_wage_rate_mandays_const = log(wage_workers_const/ mandays_workers_multi)

drop if state_code==0 | nic_3dig == 0

** Keeping only rows associated with All size classes of factories (combined) **

keep if size_class=="0_ALL"

drop if ln_lab_prod_mandays_const == . | ln_avg_wage_rate_mandays_const == . 

** Keeping only panels with data across all 21 years **

bysort state_code nic_3dig : gen state_nic_freq = _N
drop if state_nic_freq<21

gen panelvar=string( state_code ,"%02.0f")+string( nic_3dig ,"%02.0f")
encode panelvar , gen(pvar)
xtset pvar fin_year
sort pvar fin_year

xtunitroot ips ln_lab_prod_mandays_const , trend lags(aic) demean
xtunitroot ips ln_avg_wage_rate_mandays_const , trend lags(aic) demean

gen v1 = ln_lab_prod_mandays_const
gen v2 = ln_avg_wage_rate_mandays_const

*xtcointtest pedroni ln_lab_prod_mandays_const ln_avg_wage_rate_mandays_const, trend lags(aic) demean
* xtcointtest pedroni v1 v2, trend lags(aic) demean

pvarsoc v1 v2, pvaropts(instlags(1/5) gmmstyle)

pvar v1 v2, lags(4)

pvargranger

****************************** LARGE *******************************************************

clear
import delimited "C:\Users\abhin\Documents\Acads\CDS\employment_vars_state_indus_sizewise.csv"
cd "C:\Users\abhin\Documents\Acads\CDS\"

gen lab_prod_mandays_const = nva_const/ mandays_workers_multi
gen avg_wage_rate_mandays_const = wage_workers_const/ mandays_workers_multi

gen ln_lab_prod_mandays_const = log(nva_const/ mandays_workers_multi)
gen ln_avg_wage_rate_mandays_const = log(wage_workers_const/ mandays_workers_multi)

drop if state_code==0 | nic_3dig == 0

** Keeping only rows associated with Large size class of factories (aggregate) **

keep if size_class=="1_L"

drop if ln_lab_prod_mandays_const == . | ln_avg_wage_rate_mandays_const == . 
bysort state_code nic_3dig : gen state_nic_freq = _N
drop if state_nic_freq<21

gen panelvar=string( state_code ,"%02.0f")+string( nic_3dig ,"%02.0f")
encode panelvar , gen(pvar)
xtset pvar fin_year
sort pvar fin_year

xtunitroot ips ln_lab_prod_mandays_const , trend lags(aic) demean
xtunitroot ips ln_avg_wage_rate_mandays_const , trend lags(aic) demean

gen v1 = ln_lab_prod_mandays_const
gen v2 = ln_avg_wage_rate_mandays_const

pvarsoc v1 v2, pvaropts(instlags(1/5) gmmstyle)

pvar v1 v2, lags(4)

pvargranger

pvarstable, graph

****************************** MEDIUM *******************************************************

clear
import delimited "C:\Users\abhin\Documents\Acads\CDS\employment_vars_state_indus_sizewise.csv"
cd "C:\Users\abhin\Documents\Acads\CDS\"

gen lab_prod_mandays_const = nva_const/ mandays_workers_multi
gen avg_wage_rate_mandays_const = wage_workers_const/ mandays_workers_multi

gen ln_lab_prod_mandays_const = log(nva_const/ mandays_workers_multi)
gen ln_avg_wage_rate_mandays_const = log(wage_workers_const/ mandays_workers_multi)

drop if state_code==0 | nic_3dig == 0

** Keeping only rows associated with Medium size class of factories (aggregate) **

keep if size_class=="2_MED"
drop if ln_lab_prod_mandays_const == . | ln_avg_wage_rate_mandays_const == . 
bysort state_code nic_3dig : gen state_nic_freq = _N
drop if state_nic_freq<21

gen panelvar=string( state_code ,"%02.0f")+string( nic_3dig ,"%02.0f")
encode panelvar , gen(pvar)
xtset pvar fin_year
sort pvar fin_year

xtunitroot ips ln_lab_prod_mandays_const , trend lags(aic) demean
xtunitroot ips ln_avg_wage_rate_mandays_const , trend lags(aic) demean

gen v1 = ln_lab_prod_mandays_const
gen v2 = ln_avg_wage_rate_mandays_const

pvarsoc v1 v2, pvaropts(instlags(1/5) gmmstyle)

pvar v1 v2, lags(4)

pvargranger

pvarstable, graph

****************************** SMALL *******************************************************

clear
import delimited "C:\Users\abhin\Documents\Acads\CDS\employment_vars_state_indus_sizewise.csv"
cd "C:\Users\abhin\Documents\Acads\CDS\"

gen lab_prod_mandays_const = nva_const/ mandays_workers_multi
gen avg_wage_rate_mandays_const = wage_workers_const/ mandays_workers_multi

gen ln_lab_prod_mandays_const = log(nva_const/ mandays_workers_multi)
gen ln_avg_wage_rate_mandays_const = log(wage_workers_const/ mandays_workers_multi)

drop if state_code==0 | nic_3dig == 0

** Keeping only rows associated with Small size class of factories (aggregate) **

keep if size_class=="3_SM"

drop if ln_lab_prod_mandays_const == . | ln_avg_wage_rate_mandays_const == . 
bysort state_code nic_3dig : gen state_nic_freq = _N
drop if state_nic_freq<21

gen panelvar=string( state_code ,"%02.0f")+string( nic_3dig ,"%02.0f")
encode panelvar , gen(pvar)
xtset pvar fin_year
sort pvar fin_year

xtunitroot ips ln_lab_prod_mandays_const , trend lags(aic) demean
xtunitroot ips ln_avg_wage_rate_mandays_const , trend lags(aic) demean

gen v1 = ln_lab_prod_mandays_const
gen v2 = ln_avg_wage_rate_mandays_const

pvarsoc v1 v2, pvaropts(instlags(1/5) gmmstyle)

pvar v1 v2, lags(4)

pvargranger

pvarstable, graph

*************************************************************************************
*************************************************************************************
*************************************************************************************
*************************************************************************************